<?php
/**
 * @author Alecsandru Gabriel DINU
 * @since Jun 13, 2008
 */

if (!class_exists('Log')) {

	require_once("lib/Zend/Log.php");	
	require_once("lib/Zend/Log/Writer/Stream.php");
	
	/**
	 * Simple logging facade
	 *
	 */
	class Log {
	    private $caller = "";
	    private $logger;
	
	    public function __construct($file, $class, $logFile) {
	    	if (isset($class) && trim($class) != '') {
				$this->caller = $class . ":";
	    	} else if (isset($file) && trim($file) != '') {
	    		$this->caller = $file . ":";
	    	}
	    	
			$format = '[%priorityName%] ' . $this->caller .  ' %message%' . PHP_EOL;
			$formatter = new Zend_Log_Formatter_Simple($format);
	    	
	    	$writer = new Zend_Log_Writer_Stream($logFile);
	    	$writer->setFormatter($formatter);
	    	
	    	$this->logger = new Zend_Log($writer);
	    	
	    }

	    public function debug($message) {
			$this->logger->log($message, Zend_Log::DEBUG);
	    }
	    
	    public function info($message) {
			$this->logger->log($message, Zend_Log::INFO);	    	
	    }
	    
	    public function warn($message) {
			$this->logger->log($message, Zend_Log::WARN);	    
		}
	    
	    public function error($message) {
			$this->logger->log($message, Zend_Log::ERR);
	    }
	    
	    public function fatal($message) {
			$this->logger->log($message, Zend_Log::EMERG);	    	
	    }
	    
	}
}	